﻿@using MobiShop.Models
@model MobiShop.Models.FindAccountData

@{
    ViewBag.Title = "Quản lý tài khoản";
    Layout = "~/Views/Shared/_AdminStart.cshtml";
    if (ViewBag.SoKetQua == null)
    {
        ViewBag.SoKetQua = 0;
    }
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div class="titleForm">
    <h3>Quản lý Người Dùng</h3>
</div>

<div class="linkCommand">
     @Html.ActionLink("Thêm mới", "accountCreate")
</div>

@using (Html.BeginForm("accountList", "Admin", new { id = 1 }, FormMethod.Get))
    {
    @Html.ValidationSummary(true)

    <div class="boxtCreateCenter" style="width:500px;" >
        <fieldset >
            <legend>Tìm kiếm tài khoản</legend>
            <table>
                <tr>
                    <td style="width:80px;">
                        @Html.LabelFor(model => model.username)
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.username, new { style = "width:200px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.name)
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.name, new { style = "width:200px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.address)
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.address, new { style = "width:200px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.phoneNumber)
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.phoneNumber)
                        @Html.ValidationMessageFor(model => model.phoneNumber)
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.email)
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.email, new { style = "width:200px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.role)
                    </td>
                    <td>
                        @Html.DropDownListFor(model => model.role, (List<SelectListItem>)ViewBag.RoleListItem)
                        @Html.ValidationMessageFor(model => model.role)
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.visible)
                    </td>
                    <td>
                        @Html.DropDownListFor(model => model.visible, (List<SelectListItem>)ViewBag.VisibleListItem)
                        @Html.ValidationMessageFor(model => model.visible)
                    </td>
                </tr>
                <tr>
                    <td>
                    
                    </td>
                    <td>
                        <input type="submit" value="Tìm kiếm" id="btnSeach" />
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
    }
Tìm được tất cả @ViewBag.SoKetQua kết quả <br />
<a href="@ViewBag.CurrentLink" style="font-size:16px;">Refesh</a>


<div>
    <table cellspacing="1" cellpadding="5">
        <tr class="boxListHeader">
            <th style = "width:60px">
                Thao tác
            </th>
            <th style = "width:130px">
                Tên người dùng
            </th>
            <th>
                Địa chỉ
            </th>
            <th>
                Ngày sinh
            </th>
            <th>
                Điện thoại
            </th>
            <th>
                email
            </th>
            <th>
                Tài Khoản
            </th>
            <th>
                Vai Trò
            </th>
            <th>
                CreditCard Number
            </th>
            <th>
                Kích hoạt
            </th>
        </tr>
@{
    int i= 0;
    string stypeCSS = "";
}
    @if (ViewBag.ResultList != null)
    {
        foreach (Account item in ViewBag.ResultList)
        {
            i++;

            if (i % 2 == 0)
            {
                stypeCSS = "boxList1";
            }
            else
            {
                stypeCSS = "boxList2";
            }
        <tr class ="@stypeCSS">
            <td>
                @Html.ActionLink("Edit", "accountEdit", new { id = item.id }) |
                @Html.ActionLink("Delete", "accountDelete", new { id = item.id })
            </td>
            <td>
                @item.name
            </td>
            <td>
                @item.address
            </td>
            <td>
                @String.Format("{0:MM/dd/yyyy}", item.birthday)
            </td>
            <td>
                @item.phoneNumber
            </td>
            <td>
                @item.email
            </td>
            <td>
                @item.username
            </td>
            <td>
                @item.role
            </td>
            <td>
                @item.creditCardNumber
            </td>
            <td>
                @if (item.visible != null && item.visible.Value)
                {
                    <span>Đã kích hoạt</span>
                }
                else
                {
                    <span>Chưa kích hoạt</span>
                }
            </td>
        </tr>
        }
    }
    </table>
</div>

@if (ViewBag._tongSoTrang != null && (int)ViewBag._tongSoTrang >= 1)
{
    @Html.Partial("_BoPhanTrang")
}
